package com.xinou.daily_report.controller;


import com.xinou.common.base.config.ApiResponse;
import com.xinou.daily_report.PO.NotificationPO;
import com.xinou.daily_report.PO.NotificationUpdatePO;
import com.xinou.daily_report.VO.NotificationVO;
import com.xinou.daily_report.service.SysNotificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-06-11
 */
@RestController
@RequestMapping("/mini/notification")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(tags = {"前台通报"})
public class MiniNotificationController {
    private final SysNotificationService sysNotificationService;

    @PostMapping("/list")
    @ApiOperation("获取通报列表")
    @RequiresPermissions({"mini:notification:list"})
    public ApiResponse<NotificationVO> notificationList(@RequestBody NotificationPO notificationPO){
        return sysNotificationService.notificationList(notificationPO);
    }

    @PostMapping("/save")
    @ApiOperation("添加通报")
    @RequiresPermissions({"mini:notification:save"})
    public ApiResponse<Void> notificationSave(@RequestBody NotificationPO notificationPO){
        return sysNotificationService.notificationSave(notificationPO);
    }

    @PostMapping("/update")
    @ApiOperation("修改通报")
    @RequiresPermissions({"mini:notification:update"})
    public ApiResponse<Void> notificationUpdate(@RequestBody NotificationUpdatePO notificationPO){
        return sysNotificationService.notificationUpdate(notificationPO);
    }


    @PostMapping("/delete")
    @ApiOperation("删除通报")
    @RequiresPermissions({"mini:notification:delete"})
    public ApiResponse<Void> notificationDelete(@RequestBody NotificationPO notificationPO){
        return sysNotificationService.notificationDelete(notificationPO);
    }

    @PostMapping("/getById")
    @ApiOperation("根据id查询通报")
    @RequiresPermissions({"mini:notification:getById"})
    public ApiResponse<NotificationVO> notificationGetById(@RequestBody NotificationPO notificationPO){
        return sysNotificationService.notificationGetById(notificationPO);
    }

}

